package homework;

import java.util.Objects;

public class Homework_P1M3_4_Student {
  	// 学号、姓名、年龄
    private String name;
    private int id;
    private int age;
    
  	// 有参构造
    Homework_P1M3_4_Student(int id,String name,int age){
        setId(id);
        setName(name);
        setAge(age);
    }

    public void setAge(int age) {
        this.age = age;
    }
    public void setId(int id) {
        this.id = id;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public int getId() {
        return id;
    }
    public String getName() {
        return name;
    }
  
  	// 用学号作为对象的等价标准
    @Override
    public boolean equals(Object obj) {
        if (this==obj) return true;
        if(obj==null||this.getClass()!=obj.getClass())return false;
        Homework_P1M3_4_Student b = (Homework_P1M3_4_Student)obj;
        return id==b.id;
    }
  	
  	// 返回学号的哈希码
    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
  
  	// 打印对象输出格式
    @Override
    public String toString() {
        return "id：" + id + ", name：'" + name + "',age："+age;
    }
}

